<html>
<head><meta charset="utf-8"><title>Whither *Atomic API duplication · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html">Whither *Atomic API duplication</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214992291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/214992291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#214992291">(Oct 29 2020 at 16:28)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="120791">@RalfJ</span> , I wanted to check in with you about some discussion related to Rust PR <a href="https://github.com/rust-lang/rust/issues/58611">#58611</a></p>



<a name="214992353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/214992353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#214992353">(Oct 29 2020 at 16:28)</a>:</h4>
<p>You said said in closing that PR that the team wanted to first do some exploration to figure out <em>which</em> solution they would adopt</p>



<a name="214992440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/214992440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#214992440">(Oct 29 2020 at 16:29)</a>:</h4>
<p>I wanted to first see if the wg-ucg <strong>is</strong> the group doing that investigation, or if you meant it to be the job of T-compiler (or T-libs, etc...)</p>



<a name="215018675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215018675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215018675">(Oct 29 2020 at 19:49)</a>:</h4>
<p>I think it is mostly a T-lang job. The current status is:</p>
<ul>
<li>there <a href="https://paper.dropbox.com/doc/Lang-Team-Design-Meeting-and-Deferenceable--AvT5LmzDfgLQRDF8YyG0utbmAg-enTyRslkuAcNPgqWsN4UU">was a T-lang discussion </a> mapping out some of the design space but without a conclusion</li>
<li>since then, there was an <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">interesting proposal</a> that looks like it would fix the problem for <code>Arc</code> from a Stacked Borrows perspective, but it would not fix the other issues around the <code>dereferencable</code> attribute and it would likely not result in us being able to communicate anything more than "dereferencable on function entry" to LLVM.</li>
</ul>



<a name="215018797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215018797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215018797">(Oct 29 2020 at 19:50)</a>:</h4>
<p>also see <a href="https://github.com/rust-lang/rust/issues/55005#issuecomment-608566917">this GH thread</a></p>



<a name="215093138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093138">(Oct 30 2020 at 13:21)</a>:</h4>
<p>I am trying to figure out if we should <em>still</em> have the <code>*const AtomicT</code> methods anyway</p>



<a name="215093211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093211">(Oct 30 2020 at 13:22)</a>:</h4>
<p>because there may be scenarios where people want to do these "final decrements" of ref-counts</p>



<a name="215093214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093214">(Oct 30 2020 at 13:22)</a>:</h4>
<p>on their own data types</p>



<a name="215093421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093421">(Oct 30 2020 at 13:24)</a>:</h4>
<p>I suppose part of my problem is that I do not understand the <code>&amp;unsafe</code> proposal</p>



<a name="215093474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093474">(Oct 30 2020 at 13:24)</a>:</h4>
<p>and so I have not yet understood why we would delay adding the atomic methods in anticipation of an <code>&amp;unsafe</code> option</p>



<a name="215093727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093727">(Oct 30 2020 at 13:27)</a>:</h4>
<p>On a related note: Would working around the absence of *Atomic-based methods by taking a <code>input: *const Atomic</code> and then doing <code>&amp;*input</code> to turn it into a <code>&amp;Atomic</code> for the purposes of the (final) method invocation be fundamentally wrong? that is, would the lifetime of the reference in <em>that</em> case still be too long as to cause instant UB?</p>



<a name="215093847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093847">(Oct 30 2020 at 13:28)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ^</p>



<a name="215093893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215093893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215093893">(Oct 30 2020 at 13:28)</a>:</h4>
<p>(also, I guess I should move this up to the #t-lang stream, based on ralf's feedback above...)</p>



<a name="215095681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215095681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Notification Bot <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215095681">(Oct 30 2020 at 13:44)</a>:</h4>
<p>This topic was moved here from #<strong>t-lang/wg-unsafe-code-guidelines&gt;Whither *Atomic API duplication</strong> by <span class="user-mention silent" data-user-id="116083">pnkfelix</span></p>



<a name="215097771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215097771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215097771">(Oct 30 2020 at 14:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215093727">said</a>:</p>
<blockquote>
<p>On a related note: Would working around the absence of *Atomic-based methods by taking a <code>input: *const Atomic</code> and then doing <code>&amp;*input</code> to turn it into a <code>&amp;Atomic</code> for the purposes of the (final) method invocation be fundamentally wrong? that is, would the lifetime of the reference in <em>that</em> case still be too long as to cause instant UB?</p>
</blockquote>
<p>I guess it would still be fundamentally wrong.</p>



<a name="215097861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215097861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215097861">(Oct 30 2020 at 14:01)</a>:</h4>
<p>(now that I've reflected more on the fact that you'd still have that call on a <code>&amp;self</code> there, with the potentially for a concurrent method to actually do the subsequent free.)</p>



<a name="215111096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111096">(Oct 30 2020 at 15:37)</a>:</h4>
<p>Just had phone conversation with niko. Outcome: We think adding either free functions or methods on <code>*const Atomic</code> makes sense, because there is a real-world (lack of) expressiveness bug today. The reasoning that led us there was involved enough that it also probably make sense to put together an RFC for this.</p>



<a name="215111131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111131">(Oct 30 2020 at 15:37)</a>:</h4>
<p>(and I plan to draft an RFC soon)</p>



<a name="215111263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111263">(Oct 30 2020 at 15:38)</a>:</h4>
<p>hm it does feel really unfortunate to (eventually?) stabilize basically 2x the API surface here</p>



<a name="215111392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111392">(Oct 30 2020 at 15:39)</a>:</h4>
<p>It seems really unfortunate to have to teach users which one to use</p>



<a name="215111414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111414">(Oct 30 2020 at 15:39)</a>:</h4>
<p>I don't think you can avoid that, though</p>



<a name="215111427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111427">(Oct 30 2020 at 15:39)</a>:</h4>
<p>without giving up optimization opportunities</p>



<a name="215111525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111525">(Oct 30 2020 at 15:40)</a>:</h4>
<p>because either you change the rules everywhere (which gives up optimization opportunities)</p>



<a name="215111527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111527">(Oct 30 2020 at 15:40)</a>:</h4>
<p>I guess my point is that I am really skeptical about optimization around here, personally</p>



<a name="215111591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111591">(Oct 30 2020 at 15:40)</a>:</h4>
<p>like I can't see LLVM doing anything different for these methods, given you're pretty much guaranteed to be calling them on a &amp;Atomic anyway, right?</p>



<a name="215111679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111679">(Oct 30 2020 at 15:41)</a>:</h4>
<p>no, I don't think so</p>



<a name="215111709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111709">(Oct 30 2020 at 15:41)</a>:</h4>
<p>As in, the <code>&amp;Atomic</code> should be dead by the time you call the method on the <code>*const Atomic</code></p>



<a name="215111711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111711">(Oct 30 2020 at 15:41)</a>:</h4>
<p>Why would it change to <code>&amp;Atomic</code> internally? the ultimate implementations just operate on <code>*mut T</code> after digging the <code>UnsafeCell</code> -- but I guess we may want a pointer version of <code>UnsafeCell::get</code> (edit: there is <code>raw_get</code>)</p>



<a name="215111764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111764">(Oct 30 2020 at 15:42)</a>:</h4>
<p>How do you get the *const Atomic then? raw-ref on fields?</p>



<a name="215111798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111798">(Oct 30 2020 at 15:42)</a>:</h4>
<p>Well, for my use-case of <code>Arc</code></p>



<a name="215111817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111817">(Oct 30 2020 at 15:42)</a>:</h4>
<p>you get the <code>&amp;Atomic</code> early on</p>



<a name="215111829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111829">(Oct 30 2020 at 15:42)</a>:</h4>
<p>cast it</p>



<a name="215111835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111835">(Oct 30 2020 at 15:42)</a>:</h4>
<p>then it dies</p>



<a name="215111856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111856">(Oct 30 2020 at 15:42)</a>:</h4>
<p>while you still hold on to the <code>*const Atomic</code></p>



<a name="215111896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111896">(Oct 30 2020 at 15:43)</a>:</h4>
<p>Having said that, I would be happy to recommend people use <code>raw-ref</code> or whatever (<code>&amp;raw</code>? )</p>



<a name="215111926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111926">(Oct 30 2020 at 15:43)</a>:</h4>
<p>I guess it is unclear to me on this "then it dies" actually working</p>



<a name="215111970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111970">(Oct 30 2020 at 15:43)</a>:</h4>
<p>(I guess it must, since otherwise you would never be able to deallocate memory)</p>



<a name="215111977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215111977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215111977">(Oct 30 2020 at 15:43)</a>:</h4>
<p>right</p>



<a name="215112017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112017">(Oct 30 2020 at 15:44)</a>:</h4>
<p>I want to give people the option to actually say the right thing</p>



<a name="215112056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112056">(Oct 30 2020 at 15:44)</a>:</h4>
<p>right now, they cannot express it</p>



<a name="215112125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112125">(Oct 30 2020 at 15:44)</a>:</h4>
<p>I am uncertain how much the additional dereferenceable attribute buys us here</p>



<a name="215112234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112234">(Oct 30 2020 at 15:45)</a>:</h4>
<p>I do not like the perspective of focusing on LLVM optimizations for the decision here</p>



<a name="215112253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112253">(Oct 30 2020 at 15:45)</a>:</h4>
<p>I prefer to ask: What is the language's semantic model</p>



<a name="215112276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112276">(Oct 30 2020 at 15:45)</a>:</h4>
<p>and the only semantic model that would allow this</p>



<a name="215112327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112327">(Oct 30 2020 at 15:46)</a>:</h4>
<p>is one that says <code>x: &amp;T</code> can actually be deallocated</p>



<a name="215112357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112357">(Oct 30 2020 at 15:46)</a>:</h4>
<p>(that is, a <code>x: &amp;T</code> parameter to a function)</p>



<a name="215112378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112378">(Oct 30 2020 at 15:46)</a>:</h4>
<p>can be deallocated sometime during the function's execution</p>



<a name="215112389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112389">(Oct 30 2020 at 15:46)</a>:</h4>
<p>Yeah. I guess it seems unfortunate that if we stabilize the *const API, we'll likely end up with 3 in the end: *const Atomic, &amp;Atomic, and &amp;unsafe Atomic</p>



<a name="215112434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112434">(Oct 30 2020 at 15:47)</a>:</h4>
<p>I do not yet understand the <code>&amp;unsafe</code> proposal</p>



<a name="215112455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112455">(Oct 30 2020 at 15:47)</a>:</h4>
<p>niko outlined the intent to me</p>



<a name="215112463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112463">(Oct 30 2020 at 15:47)</a>:</h4>
<p>sure, it's not well defined</p>



<a name="215112535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112535">(Oct 30 2020 at 15:47)</a>:</h4>
<p>but I think it is bad to be sitting in a situation where there is real world code that is trying to make their own Arc's or whatever</p>



<a name="215112643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112643">(Oct 30 2020 at 15:48)</a>:</h4>
<p>and they literally cannot write something correct</p>



<a name="215112681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112681">(Oct 30 2020 at 15:48)</a>:</h4>
<p>sure, I agree with that</p>



<a name="215112765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112765">(Oct 30 2020 at 15:49)</a>:</h4>
<p>Also maybe API duplication is not the right way to look at this</p>



<a name="215112797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112797">(Oct 30 2020 at 15:49)</a>:</h4>
<p>It just feels really awkward to have *const taking methods whose safety comment is basically "this must be a reference"</p>



<a name="215112822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112822">(Oct 30 2020 at 15:49)</a>:</h4>
<p>?</p>



<a name="215112844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112844">(Oct 30 2020 at 15:49)</a>:</h4>
<p>is that the safety comment?</p>



<a name="215112851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112851">(Oct 30 2020 at 15:49)</a>:</h4>
<p>/me thinks</p>



<a name="215112854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112854">(Oct 30 2020 at 15:49)</a>:</h4>
<p>What else is it?</p>



<a name="215112960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215112960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215112960">(Oct 30 2020 at 15:50)</a>:</h4>
<p>I think the point is that it needs to be something weaker</p>



<a name="215113009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113009">(Oct 30 2020 at 15:50)</a>:</h4>
<p>Not on entry</p>



<a name="215113010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113010">(Oct 30 2020 at 15:50)</a>:</h4>
<p>that allows for the concurrent deallocation after the side-effect happens</p>



<a name="215113019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113019">(Oct 30 2020 at 15:50)</a>:</h4>
<p>right</p>



<a name="215113034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113034">(Oct 30 2020 at 15:51)</a>:</h4>
<p>this must be a reference on method entry</p>



<a name="215113050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113050">(Oct 30 2020 at 15:51)</a>:</h4>
<p>that <em>is</em> weaker</p>



<a name="215113078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113078">(Oct 30 2020 at 15:51)</a>:</h4>
<p>hm, I suppose so</p>



<a name="215113107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113107">(Oct 30 2020 at 15:51)</a>:</h4>
<p>(unless one takes the attitude that all <code>x: &amp;T</code> parameters could be written with that safety condition instead.)</p>



<a name="215113120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113120">(Oct 30 2020 at 15:51)</a>:</h4>
<p>(but I don't have that perspective)</p>



<a name="215113254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113254">(Oct 30 2020 at 15:52)</a>:</h4>
<p>ok, I'm convinced that there is sufficient difference in some sense</p>



<a name="215113668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113668">(Oct 30 2020 at 15:55)</a>:</h4>
<p>niko and I were debating about whether free functions or methods would be best here</p>



<a name="215113768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113768">(Oct 30 2020 at 15:55)</a>:</h4>
<p>I'm probably going to see if I can get an <code>impl *const AtomicFoo { fn raw_action(self, ...) { ... } ... }</code> going</p>



<a name="215113803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113803">(Oct 30 2020 at 15:56)</a>:</h4>
<p>(in <code>core</code>)</p>



<a name="215113849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113849">(Oct 30 2020 at 15:56)</a>:</h4>
<p>but this point about confusion about which to use</p>



<a name="215113863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113863">(Oct 30 2020 at 15:56)</a>:</h4>
<p>I think you want <code>impl AtomicFoo { fn raw_action(*const Self, ...) {} }</code></p>



<a name="215113865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113865">(Oct 30 2020 at 15:56)</a>:</h4>
<p>makes me wonder if free functions <em>are</em> better here</p>



<a name="215113891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113891">(Oct 30 2020 at 15:56)</a>:</h4>
<p>right, but we do not support <code>*const Self</code> today, no?</p>



<a name="215113901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113901">(Oct 30 2020 at 15:56)</a>:</h4>
<p>I think we do</p>



<a name="215113920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113920">(Oct 30 2020 at 15:56)</a>:</h4>
<p>Okay I'll have to look.</p>



<a name="215113956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113956">(Oct 30 2020 at 15:56)</a>:</h4>
<p>in any case</p>



<a name="215113985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113985">(Oct 30 2020 at 15:57)</a>:</h4>
<p>the scenario where you want to use the <code>*const</code> variants</p>



<a name="215113995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215113995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215113995">(Oct 30 2020 at 15:57)</a>:</h4>
<p>does seem so niche</p>



<a name="215114003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114003">(Oct 30 2020 at 15:57)</a>:</h4>
<p>ah well not stable</p>



<a name="215114018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114018">(Oct 30 2020 at 15:57)</a>:</h4>
<p>(and one where one must think very carefully)</p>



<a name="215114035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114035">(Oct 30 2020 at 15:57)</a>:</h4>
<p>I wonder if <a href="https://en.cppreference.com/w/cpp/atomic/atomic_ref">https://en.cppreference.com/w/cpp/atomic/atomic_ref</a> is sort of relevant here</p>



<a name="215114068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114068">(Oct 30 2020 at 15:57)</a>:</h4>
<p>that I would be able to justify being forced to use free functions...</p>



<a name="215114090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114090">(Oct 30 2020 at 15:57)</a>:</h4>
<p>/me looks</p>



<a name="215114106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114106">(Oct 30 2020 at 15:57)</a>:</h4>
<p>I think no, because with these you could just cast the pointer</p>



<a name="215114204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114204">(Oct 30 2020 at 15:58)</a>:</h4>
<p>though I admit I don't fully grok why atomic_ref needed to exist in C++ either</p>



<a name="215114244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114244">(Oct 30 2020 at 15:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215114106">said</a>:</p>
<blockquote>
<p>I think no, because with these you could just cast the pointer</p>
</blockquote>
<p>sorry, what do you mean?</p>



<a name="215114301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114301">(Oct 30 2020 at 15:59)</a>:</h4>
<p>cast what to what?</p>



<a name="215114312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114312">(Oct 30 2020 at 15:59)</a>:</h4>
<p>i.e., if you want to temporarily have an atomic you can "just" <code>&amp;u32 as *const u32 as *const AtomicU32</code></p>



<a name="215114324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114324">(Oct 30 2020 at 15:59)</a>:</h4>
<p>and then call these hypothetical methods</p>



<a name="215114327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114327">(Oct 30 2020 at 15:59)</a>:</h4>
<p>but that's my point</p>



<a name="215114342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114342">(Oct 30 2020 at 15:59)</a>:</h4>
<p>I think that's an antipattern</p>



<a name="215114356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114356">(Oct 30 2020 at 15:59)</a>:</h4>
<p>the cases where you are calling <code>*const</code> <del>methods</del> variants</p>



<a name="215114408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114408">(Oct 30 2020 at 15:59)</a>:</h4>
<p>are ones where you explicitly do not want the <code>&amp;OriginalType</code> hanging around</p>



<a name="215114512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114512">(Oct 30 2020 at 16:00)</a>:</h4>
<p>correct, yes</p>



<a name="215114548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114548">(Oct 30 2020 at 16:00)</a>:</h4>
<p>though I guess the expression you wrote</p>



<a name="215114559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114559">(Oct 30 2020 at 16:00)</a>:</h4>
<p>...</p>



<a name="215114564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114564">(Oct 30 2020 at 16:00)</a>:</h4>
<p>/me thinkis</p>



<a name="215114611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114611">(Oct 30 2020 at 16:00)</a>:</h4>
<p>it might need to be like <code>raw_ref!(foo: u32)</code></p>



<a name="215114625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114625">(Oct 30 2020 at 16:01)</a>:</h4>
<p>I'm trying to remember whether the <code>&amp;u32</code> will live for the entirety of the expression there or not</p>



<a name="215114675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114675">(Oct 30 2020 at 16:01)</a>:</h4>
<p>yeah, it could well be that we should recommend the use of <code>raw_ref!</code> in these scenarios</p>



<a name="215114708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114708">(Oct 30 2020 at 16:01)</a>:</h4>
<p>and in any case</p>



<a name="215114721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114721">(Oct 30 2020 at 16:01)</a>:</h4>
<p>once you're doing that</p>



<a name="215114739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114739">(Oct 30 2020 at 16:01)</a>:</h4>
<p>is it really so bad to be calling a free function?</p>



<a name="215114858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114858">(Oct 30 2020 at 16:02)</a>:</h4>
<p>In other words, do you really want to be trying to optimize the ergonomics of calling these methods?</p>



<a name="215114908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114908">(Oct 30 2020 at 16:02)</a>:</h4>
<p>when its something where the ordering is often so important</p>



<a name="215114920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114920">(Oct 30 2020 at 16:02)</a>:</h4>
<p>I think it's just awkward to have them as free functions</p>



<a name="215114925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114925">(Oct 30 2020 at 16:02)</a>:</h4>
<p>that it might always deserve its own statement?</p>



<a name="215114936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114936">(Oct 30 2020 at 16:02)</a>:</h4>
<p>since you need them at some type anyway, right?</p>



<a name="215114969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114969">(Oct 30 2020 at 16:03)</a>:</h4>
<p>so you'd end up with <code>core::atomic::u32::sub</code></p>



<a name="215114987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114987">(Oct 30 2020 at 16:03)</a>:</h4>
<p>Ah, okay</p>



<a name="215114993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215114993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215114993">(Oct 30 2020 at 16:03)</a>:</h4>
<p>or, I guess, fetch_sub, w/e</p>



<a name="215115010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115010">(Oct 30 2020 at 16:03)</a>:</h4>
<p>that does seem annoying</p>



<a name="215115047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115047">(Oct 30 2020 at 16:03)</a>:</h4>
<p>presumably one could abstract it with a trait</p>



<a name="215115123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115123">(Oct 30 2020 at 16:04)</a>:</h4>
<p><code>raw_fetch_sub&lt;T: AtomicType&gt;(arg: *const T, delta: T) -&gt; T</code></p>



<a name="215115139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115139">(Oct 30 2020 at 16:04)</a>:</h4>
<p>right?</p>



<a name="215115235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115235">(Oct 30 2020 at 16:05)</a>:</h4>
<p>but of course the implementation then ends up relying on methods anyway</p>



<a name="215115247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115247">(Oct 30 2020 at 16:05)</a>:</h4>
<p>and we don't have T: AtomicType today</p>



<a name="215115255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115255">(Oct 30 2020 at 16:05)</a>:</h4>
<p>right, we'd have to add it</p>



<a name="215115262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115262">(Oct 30 2020 at 16:05)</a>:</h4>
<p>so it would be a lot of machinery</p>



<a name="215115265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115265">(Oct 30 2020 at 16:05)</a>:</h4>
<p>(though perhaps we should, certainly it would be useful)</p>



<a name="215115285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115285">(Oct 30 2020 at 16:05)</a>:</h4>
<p>Would it?</p>



<a name="215115287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115287">(Oct 30 2020 at 16:05)</a>:</h4>
<p>maybe</p>



<a name="215115330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115330">(Oct 30 2020 at 16:05)</a>:</h4>
<p>Presuming an eventual expansion to T: AtomicType for e.g. <code>enum Bar { Yes, No }</code></p>



<a name="215115339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115339">(Oct 30 2020 at 16:06)</a>:</h4>
<p>anyway, I'm willing to believe that methods are a better choice here based on this argument</p>



<a name="215115408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115408">(Oct 30 2020 at 16:06)</a>:</h4>
<p>oh interesting</p>



<a name="215115421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115421">(Oct 30 2020 at 16:06)</a>:</h4>
<p>perhaps with a <code>#[repr(atomic)]</code> or some such?</p>



<a name="215115422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115422">(Oct 30 2020 at 16:06)</a>:</h4>
<p>(this is what C++ gives you, btw)</p>



<a name="215115443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115443">(Oct 30 2020 at 16:06)</a>:</h4>
<p>repr(u8) or so maybe</p>



<a name="215115465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115465">(Oct 30 2020 at 16:06)</a>:</h4>
<p>sure, <code>#[repr(atomic, u8)]</code></p>



<a name="215115495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115495">(Oct 30 2020 at 16:07)</a>:</h4>
<p>or maybe your point is that types shouldn't have to opt-in</p>



<a name="215115524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115524">(Oct 30 2020 at 16:07)</a>:</h4>
<p>(which... I'm ... well, I'm not sure where I fall on that question)</p>



<a name="215115533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115533">(Oct 30 2020 at 16:07)</a>:</h4>
<p>yeah I don't either :)</p>



<a name="215115540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115540">(Oct 30 2020 at 16:07)</a>:</h4>
<p>anyway, that's more of an aside</p>



<a name="215115554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115554">(Oct 30 2020 at 16:07)</a>:</h4>
<p>yeah</p>



<a name="215115585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115585">(Oct 30 2020 at 16:07)</a>:</h4>
<p>I think if we did end up with T: AtomicType then we'd likely rewrite basically the whole atomic module</p>



<a name="215115652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115652">(Oct 30 2020 at 16:08)</a>:</h4>
<p>I think methods would be mostly fine</p>



<a name="215115673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115673">(Oct 30 2020 at 16:08)</a>:</h4>
<p>this can all wait for Rust 2.0</p>



<a name="215115676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115676">(Oct 30 2020 at 16:08)</a>:</h4>
<p>ha ha ha</p>



<a name="215115810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115810">(Oct 30 2020 at 16:09)</a>:</h4>
<p>coming back to the API duplication question</p>



<a name="215115834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115834">(Oct 30 2020 at 16:09)</a>:</h4>
<p>I'm wondering if it might be as simple as</p>



<a name="215115920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115920">(Oct 30 2020 at 16:10)</a>:</h4>
<p>"If you're not doing <code>unsafe</code> stuff, then you can definitely use the <code>&amp;AtomicFoo</code> methods"</p>



<a name="215115940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115940">(Oct 30 2020 at 16:10)</a>:</h4>
<p>seems true, yes</p>



<a name="215115965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115965">(Oct 30 2020 at 16:10)</a>:</h4>
<p>"If you're doing <code>unsafe</code> stuff, then you'll need to consider whether you managing memory. If so, you may need <code>*const AtomicFoo</code>"</p>



<a name="215115979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115979">(Oct 30 2020 at 16:10)</a>:</h4>
<p>I'm not sure if there's cases besides memory management that it comes up</p>



<a name="215115997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215115997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215115997">(Oct 30 2020 at 16:11)</a>:</h4>
<p>Probably better to be a little more open-ended</p>



<a name="215116086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116086">(Oct 30 2020 at 16:11)</a>:</h4>
<p>but do you see what I mean? I don't think it needs to be that difficult a question, in the hopefully common case of someone <em>not</em> using <code>unsafe</code></p>



<a name="215116097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116097">(Oct 30 2020 at 16:11)</a>:</h4>
<p>If the atomic operation can result in the memory at that address no longer being a valid AtomicFoo</p>



<a name="215116105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116105">(Oct 30 2020 at 16:11)</a>:</h4>
<p>I think</p>



<a name="215116120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116120">(Oct 30 2020 at 16:11)</a>:</h4>
<p>/me thinks</p>



<a name="215116174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116174">(Oct 30 2020 at 16:12)</a>:</h4>
<p>is there a case where that can happen that's <em>not</em> memory management stuff</p>



<a name="215116212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116212">(Oct 30 2020 at 16:12)</a>:</h4>
<p>well, in any case, your phrasing is better</p>



<a name="215116243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116243">(Oct 30 2020 at 16:12)</a>:</h4>
<p>I guess for some definition of "memory management," e.g. the temporary atomic stuff I was talking about earlier</p>



<a name="215116252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116252">(Oct 30 2020 at 16:12)</a>:</h4>
<p>I.e. I'd probably use your phrasing, and then give the example of <code>Arc</code></p>



<a name="215116292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116292">(Oct 30 2020 at 16:12)</a>:</h4>
<p>"temporary atomic stuff"</p>



<a name="215116303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116303">(Oct 30 2020 at 16:12)</a>:</h4>
<p>where e.g. you have an Arc with a thread counter or something and the AtomicU32 magically becomes a Cell&lt;u32&gt;</p>



<a name="215116322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116322">(Oct 30 2020 at 16:13)</a>:</h4>
<p>Ah okay</p>



<a name="215116348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116348">(Oct 30 2020 at 16:13)</a>:</h4>
<p>in rayon's case, it was dealing with stack memory in another thread, that will go out of scope once triggered by the atomic operation</p>



<a name="215116420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116420">(Oct 30 2020 at 16:13)</a>:</h4>
<p>ah true</p>



<a name="215116478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116478">(Oct 30 2020 at 16:14)</a>:</h4>
<p>that is arguably another kind of memory management</p>



<a name="215116484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116484">(Oct 30 2020 at 16:14)</a>:</h4>
<p>but its one that's being done under the hood</p>



<a name="215116492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116492">(Oct 30 2020 at 16:14)</a>:</h4>
<p>so its a good additional example</p>



<a name="215116648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116648">(Oct 30 2020 at 16:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215116303">said</a>:</p>
<blockquote>
<p>where e.g. you have an Arc with a thread counter or something and the AtomicU32 magically becomes a Cell&lt;u32&gt;</p>
</blockquote>
<p>where is an example of this? I'm trying to understand the scenario where such a conversion is sound. Just the case where you first prove that you are the only thread with access to the <code>AtomicU32</code> ?</p>



<a name="215116688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116688">(Oct 30 2020 at 16:16)</a>:</h4>
<p>I think so yes</p>



<a name="215116704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116704">(Oct 30 2020 at 16:16)</a>:</h4>
<p>okay</p>



<a name="215116748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116748">(Oct 30 2020 at 16:16)</a>:</h4>
<p>and that's kind of analogous to an <code>Arc</code></p>



<a name="215116769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116769">(Oct 30 2020 at 16:16)</a>:</h4>
<p>i.e. first dynamically proving uniqueness</p>



<a name="215116788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116788">(Oct 30 2020 at 16:16)</a>:</h4>
<p>anyway, I get it now</p>



<a name="215116792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116792">(Oct 30 2020 at 16:16)</a>:</h4>
<p>I think perhaps the thread counter is not <em>in</em> the arc in that case</p>



<a name="215116834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116834">(Oct 30 2020 at 16:16)</a>:</h4>
<p>(e.g., I believe C++ does this for shared_ptr, where it's an Rc until you spawn a thread)</p>



<a name="215116880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116880">(Oct 30 2020 at 16:17)</a>:</h4>
<p>Oh that's interesting</p>



<a name="215116900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116900">(Oct 30 2020 at 16:17)</a>:</h4>
<p>I didn't actually know that C++ did that</p>



<a name="215116909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116909">(Oct 30 2020 at 16:17)</a>:</h4>
<p>I just assumed everyone paid the cost all the time</p>



<a name="215116923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215116923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215116923">(Oct 30 2020 at 16:17)</a>:</h4>
<p>silly me</p>



<a name="215117064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117064">(Oct 30 2020 at 16:18)</a>:</h4>
<p><a href="https://snf.github.io/2019/02/13/shared-ptr-optimization/">https://snf.github.io/2019/02/13/shared-ptr-optimization/</a></p>



<a name="215117191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117191">(Oct 30 2020 at 16:19)</a>:</h4>
<p>I wonder if our <code>Arc</code> could do that</p>



<a name="215117212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117212">(Oct 30 2020 at 16:19)</a>:</h4>
<p>it's not exactly "until you spawn a thread", but whether <code>pthread_create</code> is linked</p>



<a name="215117214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117214">(Oct 30 2020 at 16:19)</a>:</h4>
<p>it probably isn't worth the effort, given that we have <code>Rc</code></p>



<a name="215117225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117225">(Oct 30 2020 at 16:19)</a>:</h4>
<p>oh</p>



<a name="215117243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117243">(Oct 30 2020 at 16:19)</a>:</h4>
<p>that's not quite as exciting</p>



<a name="215117291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117291">(Oct 30 2020 at 16:20)</a>:</h4>
<p>/me reads the blog post</p>



<a name="215117503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117503">(Oct 30 2020 at 16:21)</a>:</h4>
<p>wow that blog post is really cool, in terms of the diving into scenarios where the stdlib <em>fails</em> to detect potential threading</p>



<a name="215117537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117537">(Oct 30 2020 at 16:21)</a>:</h4>
<p>(the "shared library loaded by static binary" scenario)</p>



<a name="215117697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117697">(Oct 30 2020 at 16:22)</a>:</h4>
<p>oh and it looks like VisualC++ does not seem to have this optimization</p>



<a name="215117747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215117747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215117747">(Oct 30 2020 at 16:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215117191">said</a>:</p>
<blockquote>
<p>I wonder if our <code>Arc</code> could do that</p>
</blockquote>
<p>(heh the blog post even addresses this line of thought)</p>



<a name="215120914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215120914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215120914">(Oct 30 2020 at 16:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215114035">said</a>:</p>
<blockquote>
<p>I wonder if <a href="https://en.cppreference.com/w/cpp/atomic/atomic_ref">https://en.cppreference.com/w/cpp/atomic/atomic_ref</a> is sort of relevant here</p>
</blockquote>
<p>AFAICT, <code>atomic_ref</code> allows you to use atomic operations on something that you can also do non-atomic operations on, because IIRC converting <code>atomic&lt;T&gt; *</code> to <code>T *</code> is UB in C++ due to C++ supporting TBAA.</p>



<a name="215126405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215126405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215126405">(Oct 30 2020 at 17:31)</a>:</h4>
<p>Ah, TBAA makes sense as the reason.</p>



<a name="215188790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215188790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215188790">(Oct 31 2020 at 12:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215111096">said</a>:</p>
<blockquote>
<p>Just had phone conversation with niko. Outcome: We think adding either free functions or methods on <code>*const Atomic</code> makes sense, because there is a real-world (lack of) expressiveness bug today. The reasoning that led us there was involved enough that it also probably make sense to put together an RFC for this.</p>
</blockquote>
<p>looking forward to that RFC... I don't see why we'd need these functions if we find a good solution to the <code>Arc</code>-<code>dereferencable</code> problem (and I do not consider these functions a good solution)</p>



<a name="215188865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215188865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215188865">(Oct 31 2020 at 12:14)</a>:</h4>
<blockquote>
<p>pnkfelix: and the only semantic model that would allow this<br>
pnkfelix: is one that says x: &amp;T can actually be deallocated<br>
pnkfelix: (that is, a x: &amp;T parameter to a function)<br>
pnkfelix: can be deallocated sometime during the function's execution</p>
</blockquote>
<p>Yes. But that on its own seems fine to me, if it does not cause other problems (such as missed optimizations).</p>



<a name="215188907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215188907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215188907">(Oct 31 2020 at 12:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215120914">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215114035">said</a>:</p>
<blockquote>
<p>I wonder if <a href="https://en.cppreference.com/w/cpp/atomic/atomic_ref">https://en.cppreference.com/w/cpp/atomic/atomic_ref</a> is sort of relevant here</p>
</blockquote>
<p>AFAICT, <code>atomic_ref</code> allows you to use atomic operations on something that you can also do non-atomic operations on, because IIRC converting <code>atomic&lt;T&gt; *</code> to <code>T *</code> is UB in C++ due to C++ supporting TBAA.</p>
</blockquote>
<p>FWIW, we have kind of the inverse in Rust, with <code>get_mut</code> methods on our <code>Atomic*</code> types</p>



<a name="215188914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215188914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215188914">(Oct 31 2020 at 12:14)</a>:</h4>
<p>this poses some really nasty questions around compare-and-swap on uninit memory... but let's not go there in this thread ;)</p>



<a name="215361543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361543">(Nov 02 2020 at 18:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> one comment here is that I would expect to just tell people to <em>always</em> use the <code>*const</code> version of the methods</p>



<a name="215361554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361554">(Nov 02 2020 at 18:51)</a>:</h4>
<p>not to say I don't agree with the downsides</p>



<a name="215361681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361681">(Nov 02 2020 at 18:52)</a>:</h4>
<p>Well, ok, I guess that makes them <code>unsafe</code> functions</p>



<a name="215361687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361687">(Nov 02 2020 at 18:52)</a>:</h4>
<p>/me sighs</p>



<a name="215361697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361697">(Nov 02 2020 at 18:53)</a>:</h4>
<p>I had kind of forgotten about that, I admit</p>



<a name="215361794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361794">(Nov 02 2020 at 18:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215115920">said</a>:</p>
<blockquote>
<p>"If you're not doing <code>unsafe</code> stuff, then you can definitely use the <code>&amp;AtomicFoo</code> methods"</p>
</blockquote>
<p>that was my motivation for this rule of thumb</p>



<a name="215361872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361872">(Nov 02 2020 at 18:54)</a>:</h4>
<p>One of the things that I keep thinking is that this "may deallocate mid-function" property almost certainly needs to extend to the caller and quite possibly caller's caller, etc</p>



<a name="215361915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361915">(Nov 02 2020 at 18:54)</a>:</h4>
<p>So it really seems like it wants to be a type, something that will be more apparent</p>



<a name="215361953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361953">(Nov 02 2020 at 18:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215188865">said</a>:</p>
<blockquote>
<blockquote>
<p>pnkfelix: and the only semantic model that would allow this<br>
pnkfelix: is one that says x: &amp;T can actually be deallocated<br>
pnkfelix: (that is, a x: &amp;T parameter to a function)<br>
pnkfelix: can be deallocated sometime during the function's execution</p>
</blockquote>
<p>Yes. But that on its own seems fine to me, if it does not cause other problems (such as missed optimizations).</p>
</blockquote>
<p>It strikes me as unintuitive, to say the least. I would have thought its simpler to say "if you get <code>&amp;T</code> as an input to a function, the <em>caller</em> is guaranteeing it will live for entirety of the call."</p>



<a name="215361962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215361962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215361962">(Nov 02 2020 at 18:55)</a>:</h4>
<p>(Something else that <span class="user-mention" data-user-id="116083">@pnkfelix</span> and I discussed is that you want the name of the method to be distinct, so that it can be more readily audited when reading PRs and the like)</p>



<a name="215362088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362088">(Nov 02 2020 at 18:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> the caller can't guarantee that, right? At least, not always. that seems to be the crux of the problem. The caller is guaranteeing it to the callee, but the callee must also guarantee it back to the caller.</p>



<a name="215362133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362133">(Nov 02 2020 at 18:56)</a>:</h4>
<p>/me thinks</p>



<a name="215362200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362200">(Nov 02 2020 at 18:57)</a>:</h4>
<p>Are there cases besides the one under discussion where it would not be realistic to make that the rule?</p>



<a name="215362362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362362">(Nov 02 2020 at 18:58)</a>:</h4>
<p>I.e., I had thought that switching to using <code>*const AtomicFoo</code> for the ref-count decrement <em>would</em> allow for a caller (or perhaps caller+callee collective, still ruminating on that)  guarantee that a <code>&amp;T</code> <em>will live</em></p>



<a name="215362409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362409">(Nov 02 2020 at 18:58)</a>:</h4>
<p>well we've long had the question of whether a function can invoke <code>free</code> on some <code>&amp;T</code> it gets (presuming it knows that to come from a <code>malloc</code> call somehow)</p>



<a name="215362449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362449">(Nov 02 2020 at 18:58)</a>:</h4>
<p>ah</p>



<a name="215362476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362476">(Nov 02 2020 at 18:59)</a>:</h4>
<p>I somehow have forgotten this debate</p>



<a name="215362485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362485">(Nov 02 2020 at 18:59)</a>:</h4>
<p>debate/question</p>



<a name="215362490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362490">(Nov 02 2020 at 18:59)</a>:</h4>
<p>it seems kind of the same to me</p>



<a name="215362715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215362715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215362715">(Nov 02 2020 at 19:01)</a>:</h4>
<p>and figured <code>*const T</code> was the answer here too</p>



<a name="215366314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215366314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215366314">(Nov 02 2020 at 19:27)</a>:</h4>
<p>I think with &amp;T it feels less obvious that you could, but the same applies to &amp;mut T, and there it is very much not obvious (e.g., ptr::drop_in_place)</p>



<a name="215383389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215383389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215383389">(Nov 02 2020 at 21:44)</a>:</h4>
<p>wait, I don't understand: <span class="user-mention" data-user-id="116122">@simulacrum</span> , are you saying you think <code>&amp;mut T</code> conveys you <em>should</em> be able to do such a deallocation?</p>



<a name="215383431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215383431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215383431">(Nov 02 2020 at 21:45)</a>:</h4>
<p><code>ptr::drop_in_place</code> doesn't take a <code>&amp;mut</code>, so I'm confused about your mentioning it.</p>



<a name="215383517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215383517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215383517">(Nov 02 2020 at 21:45)</a>:</h4>
<p>I am uncertain - I lean towards no, I think. But I am saying that of the two, &amp;mut seems more likely to be a candidate for such an operation</p>



<a name="215383604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215383604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215383604">(Nov 02 2020 at 21:46)</a>:</h4>
<p>oh, okay. More of a candidate, yes. But I still lean towards: Not a candidate. :)</p>



<a name="215384846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215384846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215384846">(Nov 02 2020 at 21:57)</a>:</h4>
<p>we have definitely been pushing towards "no"</p>



<a name="215384897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215384897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215384897">(Nov 02 2020 at 21:57)</a>:</h4>
<p>that is what permits us to do various aggressive reorderings which, the vast majority fo the time, ought to be fine</p>



<a name="215384924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215384924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215384924">(Nov 02 2020 at 21:57)</a>:</h4>
<p>and if you think (intuitively) about <em>borrowing</em>, it makes sense</p>



<a name="215384976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215384976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215384976">(Nov 02 2020 at 21:58)</a>:</h4>
<p>i.e., the caller lent you this data, they didn't say you can destroy it</p>



<a name="215385005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385005">(Nov 02 2020 at 21:58)</a>:</h4>
<p>anyway, the fly in the ointment for me is that a <code>*const T</code> version must be unsafe to call</p>



<a name="215385011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385011">(Nov 02 2020 at 21:58)</a>:</h4>
<p>that's a real drag</p>



<a name="215385033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385033">(Nov 02 2020 at 21:58)</a>:</h4>
<p>I'd like one that is safe to call with an <code>&amp;T</code> but unsafe to call with a <code>*const T</code> :)</p>



<a name="215385134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385134">(Nov 02 2020 at 21:59)</a>:</h4>
<p>(er, not sure if that makes sense, but I guess that's just "having two copies of the API surface")</p>



<a name="215385706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385706">(Nov 02 2020 at 22:04)</a>:</h4>
<p>Hmm</p>



<a name="215385751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385751">(Nov 02 2020 at 22:05)</a>:</h4>
<p>yes I think this just ... doesn't sound that bad to me</p>



<a name="215385823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215385823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215385823">(Nov 02 2020 at 22:06)</a>:</h4>
<p>Maybe I'm too willing to swallow "its not a duplicated API. One is for safe uses, the other for unsafe. And when you see the latter, you want it called out very explicitly, because Here Be Tygers"</p>



<a name="215393082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393082">(Nov 02 2020 at 23:28)</a>:</h4>
<p>I think Niko's intuition/feeling there basically matches mine, that with some compiler magic or &amp;unsafe or so we could design a better API than just duplicating, because it seems like the function ultimately does the same thing - at least in the case of atomics - just with different guarantees at the caller level. Perhaps an interesting exercise would be to try to think if we <em>could</em> just remove the additional bit that &amp;T arguably gives for these functions within the function, would that be enough? i.e. if you could call it with *const to get the less strict behavior or &amp;T to promise more, but the function of definition itself is the same</p>



<a name="215393105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393105">(Nov 02 2020 at 23:29)</a>:</h4>
<p>Sort of that the function says "I do not need this additional requirement"</p>



<a name="215393132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393132">(Nov 02 2020 at 23:29)</a>:</h4>
<p>with perhaps s/need/want, I guess.</p>



<a name="215393270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393270">(Nov 02 2020 at 23:30)</a>:</h4>
<p>I really do worry that if we do this here it'll end up being true that a bunch of APIs technically need the same treatment</p>



<a name="215393453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393453">(Nov 02 2020 at 23:32)</a>:</h4>
<p>I guess it's mainly a problem with Sync types, so that might help, but it feels like opening a can of worms.</p>



<a name="215393534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215393534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215393534">(Nov 02 2020 at 23:33)</a>:</h4>
<p>It would help me at least to actually get clarity on that - does this problem require a synchronization operation in the function to cause problems (i.e. is atomic the only API needing this in std as such?)</p>



<a name="215618809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215618809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215618809">(Nov 04 2020 at 18:00)</a>:</h4>
<p>thanks for feedback. I'll see if I can address it when I have a moment</p>



<a name="215952482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215952482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215952482">(Nov 07 2020 at 12:16)</a>:</h4>
<p>FWIW, if you only focus on Arc/Atomics, then by favorite proposal currently is <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">this one</a>. This <em>does</em> give up on "derefeerncable for the duration of the entire function call" for <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252#issuecomment-709042507">all references</a>, but all the Stacked Borrows optimizations we considered so far are preserved. (To be fair, we did not consider very many, but the basic reorderings we considered are very powerful.)</p>



<a name="215952490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215952490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215952490">(Nov 07 2020 at 12:17)</a>:</h4>
<p>This does not help with the other problems around <code>dereferencable</code>/protectors, but then you seem to not currently consider those in your discussion anyway</p>



<a name="215959392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/215959392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#215959392">(Nov 07 2020 at 15:17)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> that's interesting! I'll read into that issue</p>



<a name="216662191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/216662191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#216662191">(Nov 13 2020 at 19:37)</a>:</h4>
<p>Yes, the main pain point that I am currently focusing on is Arc/Atomics, since that is the one that I see real-world code getting burned by our (what I would call) lack of expressiveness here</p>



<a name="216662344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/216662344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#216662344">(Nov 13 2020 at 19:38)</a>:</h4>
<p>(but I remain concerned about people's overall mental model of parameters of type <code>&amp;T</code>)</p>



<a name="216662449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/216662449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#216662449">(Nov 13 2020 at 19:39)</a>:</h4>
<p>(and yes I know that I still need to post a response to simulacrum's feedback above... balancing a lot of stuff at moment)</p>



<a name="216726017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/216726017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#216726017">(Nov 14 2020 at 12:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/216662191">said</a>:</p>
<blockquote>
<p>Yes, the main pain point that I am currently focusing on is Arc/Atomics, since that is the one that I see real-world code getting burned by our (what I would call) lack of expressiveness here</p>
</blockquote>
<p>I'm a bit worried that we might end up with a partial solution, that might actually not be a good solution when/if we solve the wider problem.</p>



<a name="217909751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217909751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217909751">(Nov 25 2020 at 16:47)</a>:</h4>
<p>Okay I just re-read this whole conversation, as well as the notes from a prior <a href="https://paper.dropbox.com/doc/Lang-Team-Design-Meeting-and-Dereferenceable--BAGtOq5x6fY2s7TuGlAx~drlAg-enTyRslkuAcNPgqWsN4UU">lang team discussion</a>. My current response to <span class="user-mention" data-user-id="116122">@simulacrum</span> 's <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215393082">later points</a> is that I'm struggling to understand which proposals are trying to get away with not adding <em>any</em> new API at all (i.e. figure out a way to fix things so that all the current API's "just work", which I think is the essence of what <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> is proposing), versus which proposals are accepting that we will need to add <em>some</em> new API, and the question is whether we can stomach adding <code>*const</code> API (at least in short term), or if we must wait for <code>&amp;unsafe T</code>, or some attributes to attach to <code>&amp;T</code> parameters, etc, to get the desired effect(s).</p>



<a name="217910187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217910187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217910187">(Nov 25 2020 at 16:50)</a>:</h4>
<p>One basic goal is that I want a solution that allows a 3rd party developer to make their own <code>Arc</code>. I don't need it to be an <em>easy task</em>; I just want it to be <em>possible</em>, and I want basic things like "you can write intermediate helper functions" to work.</p>



<a name="217910316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217910316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217910316">(Nov 25 2020 at 16:51)</a>:</h4>
<p>That latter goal makes me suspicious of suggestions of compiler-magic for making <code>&amp;T</code> parameters behave special when given <code>*const T</code> inputs; e.g. consider that special-ness needs to <em>trickle down</em> through subroutine calls that pass along the <code>&amp;T</code>.</p>



<a name="217910986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217910986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217910986">(Nov 25 2020 at 16:56)</a>:</h4>
<p>Another basic goal is that I want to have a simple way to explain what a <code>&amp;T</code> formal parameter is guaranteeing from the caller, and as <span class="user-mention" data-user-id="116009">@nikomatsakis</span> rightly points out, what guarantees need to be upheld by the callee. I've been assuming that we would keep saying "it lives for the entirety of the function body", because that's just always the way I've read it. Changing it to something like "it lives up until the last access within the function body (but immediately after that last access, its possible that concurrent activity causes it to become a dangling-pointer)" is much harder for me to stomach. But I <em>can</em> stomach it; it <em>is</em> something I can explain, though it requires a lot more exposition to explain why it isn't paradoxical.</p>



<a name="217911286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217911286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217911286">(Nov 25 2020 at 16:58)</a>:</h4>
<p>(Am I correct that adopting <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> is, in spirit, much like saying "all <code>&amp;T</code> formals live up until their last access within a function body"?)</p>



<a name="217911296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217911296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217911296">(Nov 25 2020 at 16:58)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> ^</p>



<a name="217911998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217911998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217911998">(Nov 25 2020 at 17:02)</a>:</h4>
<p>(Maybe "paradoxical" is the wrong word above. I'm happy to elaborate on my concerns there, but I don't want to further derail this discussion with that digression.)</p>



<a name="217934011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/217934011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#217934011">(Nov 25 2020 at 20:17)</a>:</h4>
<p>(I will also admit that the experience of prototyping the proposal of "just" duplicating the Atomic* API with <code>raw_</code> variants has given me some appreciation for the opposing side.)</p>



<a name="218118448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218118448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218118448">(Nov 27 2020 at 18:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/217911286">said</a>:</p>
<blockquote>
<p>(Am I correct that adopting <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> is, in spirit, much like saying "all <code>&amp;T</code> formals live up until their last access within a function body"?)</p>
</blockquote>
<p><code>&amp;T</code> guarantees way more than "it lives for the entirety of the function body", at least in general -- it guarantees that nobody writes to this memory for the duration of the fn call (except for <code>UnsafeCell</code>). deallocation is IMO a (very strong) form of "writing"/mutation, and is thus also rules out. this remains true under <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> for <code>&amp;T</code> <em>without <code>UnsafeCell</code></em>.<br>
The difference comes in when there is an <code>UnsafeCell</code>. under current Stacked Borrows, the rule is that the <code>UnsafeCell</code> part of the pointee may be <em>mutated</em> but not deallocated by others. So, deallocation is "stronger than" normal mutation. <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> proposes to make them equally strong, IOW, memory that other parties may write to, may also be deallocated by those parties.</p>



<a name="218118530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218118530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218118530">(Nov 27 2020 at 18:22)</a>:</h4>
<p>there is no "until the last access" in any of this. but of course, at every access, the memory must still exist, so "until the last access" arises as a kind of emergent property.</p>



<a name="218118818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218118818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218118818">(Nov 27 2020 at 18:27)</a>:</h4>
<p><a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> implies removing <code>dereferencable</code> from <code>&amp;UnsafeCell</code> (assuming this attribute means "dereferencable for the entire fn body"), however it does so in a much more elegant way than what was discussed with the lang team back then. The downside is that it means also removing this attribute for <code>&amp;mut</code>, because where previously <em>nobody</em> was allowed to deallocate this memory, now <em>nobody else</em> (as in, no alias that might exist anywhere) is allowed to deallocate it, but the function itself may still deallocate. This is symmetric with mutation where nobody else is allowed to mutate but the function itself may mutate. I think this is beautiful but unfortunately does not match how LLVM is architected. But maybe that's okay, we'll need custom optimizations to really exploit these properties anyway.</p>



<a name="218119031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218119031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218119031">(Nov 27 2020 at 18:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/217909751">said</a>:</p>
<blockquote>
<p>Okay I just re-read this whole conversation, as well as the notes from a prior <a href="https://paper.dropbox.com/doc/Lang-Team-Design-Meeting-and-Dereferenceable--BAGtOq5x6fY2s7TuGlAx~drlAg-enTyRslkuAcNPgqWsN4UU">lang team discussion</a>. My current response to <span class="user-mention silent" data-user-id="116122">simulacrum</span> 's <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/215393082">later points</a> is that I'm struggling to understand which proposals are trying to get away with not adding <em>any</em> new API at all (i.e. figure out a way to fix things so that all the current API's "just work", which I think is the essence of what <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> is proposing), versus which proposals are accepting that we will need to add <em>some</em> new API, and the question is whether we can stomach adding <code>*const</code> API (at least in short term), or if we must wait for <code>&amp;unsafe T</code>, or some attributes to attach to <code>&amp;T</code> parameters, etc, to get the desired effect(s).</p>
</blockquote>
<p>I think one problem is that a whole host of proposals exist and they all get confused quickly and regularly.</p>



<a name="218119160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218119160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218119160">(Nov 27 2020 at 18:32)</a>:</h4>
<p>does anyone know what the status of dereferencable / dereferencable_on_entry / dereferencable_globally in LLVM is right now? <a href="https://reviews.llvm.org/D61652">https://reviews.llvm.org/D61652</a> says "accepted" but I do not see <code>dereferecable_globally</code> in the LangRef.</p>



<a name="218119560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218119560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218119560">(Nov 27 2020 at 18:39)</a>:</h4>
<p>Honestly, I think my preference is for <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a>. this means we have to remove <code>dereferencable</code> now from everything but <code>&amp;Frozen</code>, but we can add it back once LLVM changed its meaning to "dereferencable on entry".<br>
This does not solve <code>VecDeque</code> and <code>RefCell</code>, but I think that should just be fixed in the code (<code>vec_deque::Drain</code>, <code>Ref</code> and <code>RefMut</code> should use raw pointers, not references, since the lifetimes they are using are mere <em>upper bounds</em> for how long those pointers are actually valid ). It also does not fix MMIO but again that rather asks for more ergonomic raw pointers I think.<br>
My impression is that part of the problem is that there are quite a few issues put together here -- I am guilty of trying to solve them all at once as that seemed like a nice idea. But maybe it's not such a nice idea after all, and we should consider each of them in isolation.</p>



<a name="218196014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218196014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218196014">(Nov 29 2020 at 04:47)</a>:</h4>
<p>I'm trying to understand a critical part of your response here: It sounds like you're saying that <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> wouldn't even solve the problem that the deferent of a <code>&amp;AtomicUsize</code> can get deallocated by another party when it is decremented...?</p>



<a name="218196024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218196024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218196024">(Nov 29 2020 at 04:47)</a>:</h4>
<p>(i.e. that the guarantee that it must live for entirety of the function body would persist?)</p>



<a name="218196075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218196075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218196075">(Nov 29 2020 at 04:49)</a>:</h4>
<p>oh, no wait, I overlooked this sentence: "So, deallocation is "stronger than" normal mutation. <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> proposes to make them equally strong, IOW, memory that other parties may write to, may also be deallocated by those parties."</p>



<a name="218196169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218196169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218196169">(Nov 29 2020 at 04:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/218119160">said</a>:</p>
<blockquote>
<p>does anyone know what the status of dereferencable / dereferencable_on_entry / dereferencable_globally in LLVM is right now? <a href="https://reviews.llvm.org/D61652">https://reviews.llvm.org/D61652</a> says "accepted" but I do not see <code>dereferecable_globally</code> in the LangRef.</p>
</blockquote>
<p>metadata on ticket from September says it is now (as in, at that time) "ready to land"</p>



<a name="218196327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218196327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218196327">(Nov 29 2020 at 04:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/218196075">said</a>:</p>
<blockquote>
<p>oh, no wait, I overlooked this sentence: "So, deallocation is "stronger than" normal mutation. <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/252">ucg#252</a> proposes to make them equally strong, IOW, memory that other parties may write to, may also be deallocated by those parties."</p>
</blockquote>
<p>(but even here, I don't think the <code>AtomicUsize</code> in an <code>Arc</code> (or rather, <code>ArcInner</code> ...) is behind an <code>UnsafeCell</code>, is it? And in any case, you're still going to end up with an <code>&amp;AtomicUsize</code> parameter somewhere in the method call chain... <em>unless</em> we adopt a solution that involves extending the std API to allow one to use <code>*const AtomicUsize</code> for the decrements for dropping an <code>Arc</code>)</p>



<a name="218208144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218208144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218208144">(Nov 29 2020 at 11:13)</a>:</h4>
<p><code>AtomicUsize</code> is itself (wrapping) an <code>UnsafeCell&lt;usize&gt;</code> (so, IIUC, those <code>mem::size_of::&lt;usize&gt;()</code> bytes are allowed to be concurrently mutated, or even deallocated, according to this model, leading to an <code>&amp;AtomicUsize</code> only being <code>dereferenceable_on_entry</code>)</p>



<a name="218214573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218214573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218214573">(Nov 29 2020 at 14:14)</a>:</h4>
<p>right, this works because <code>AtomicUsize = UnsafeCell&lt;usize&gt;</code> (plus privacy)</p>



<a name="218214621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218214621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218214621">(Nov 29 2020 at 14:14)</a>:</h4>
<p>however, if you e.g. added a helper method on <code>&amp;ArcInner</code> that did the decrement, that would still be wrong since that reference would cover the data part, which is not (in general) interior mutable, and thus may not be deallocated by other threads</p>



<a name="218214623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218214623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218214623">(Nov 29 2020 at 14:14)</a>:</h4>
<p>but that seems reasonable to me? if other threads cannot mutate, surely they cannot deallocate?</p>



<a name="218310334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218310334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218310334">(Nov 30 2020 at 16:31)</a>:</h4>
<p>This is a detail I had been worried about, but I had been taking it from the other direction; I had been incorrectly inferring that the rules described here would <em>allow</em> a helper method on <code>&amp;ArcInner</code> that did the decrement, and I had been worrying about how to make that make sense.</p>



<a name="218310717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218310717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218310717">(Nov 30 2020 at 16:34)</a>:</h4>
<p>Overall I am actually finding the arguments given here pretty compelling. Namely the <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/218196075">one above</a> that if the compiler is forced to assume a concurrent actor can write to the <code>T</code> behind a <code>&amp;T</code>, then the compiler must also assume that a concurrent actor might deallocate the <code>T</code> there as well.</p>



<a name="218310808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218310808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218310808">(Nov 30 2020 at 16:35)</a>:</h4>
<p>I'm going to do another review of the links I gave above with that lens in place. Maybe I won't have to write an RFC for <code>*const AtomicFoo</code> methods after all. (At least not to resolve <em>my</em> problem. We may still need such methods for the other problems listed.)</p>



<a name="218315716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218315716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218315716">(Nov 30 2020 at 17:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/218310717">said</a>:</p>
<blockquote>
<p>Overall I am actually finding the arguments given here pretty compelling. Namely the <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/218196075">one above</a> that if the compiler is forced to assume a concurrent actor can write to the <code>T</code> behind a <code>&amp;T</code>, then the compiler must also assume that a concurrent actor might deallocate the <code>T</code> there as well.</p>
</blockquote>
<p>so you think it'd be okay if an <code>&amp;ArcInner</code> helper would be <em>incorrect</em>, based on the argument that parts of what that pointer points to might be immutable (when <code>T: Frozen</code>) and immutable memory may not be deallocated either?</p>



<a name="218329701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218329701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218329701">(Nov 30 2020 at 18:58)</a>:</h4>
<p>I haven't made up my mind about the <code>&amp;ArcInner</code> helper example yet. I had spent some time, when I had thought we would "have to" allow it, trying to think of how to explain the model</p>



<a name="218329974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218329974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218329974">(Nov 30 2020 at 19:00)</a>:</h4>
<p>but my main concern has always been how to even express the handling of the <code>&amp;AtomicUsize</code> itself.</p>



<a name="218330027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/218330027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#218330027">(Nov 30 2020 at 19:01)</a>:</h4>
<p>Under the rules that you and <span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> have outlined, it sounds like we need not have a problem with the handling of <code>&amp;AtomicUsize</code>.</p>



<a name="232003563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232003563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232003563">(Mar 26 2021 at 17:27)</a>:</h4>
<p>So there’s a lang team meeting coming up related to this topic, <a href="https://github.com/rust-lang/lang-team/issues/82">https://github.com/rust-lang/lang-team/issues/82</a></p>



<a name="232003686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232003686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232003686">(Mar 26 2021 at 17:28)</a>:</h4>
<p>I made a write up, then I decided the write-up was not approrpriate for the lang team meeting (too long winded), so I turned it into a blog post because I couldn’t bear to throw it away: <a href="http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/">http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/</a></p>



<a name="232003761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232003761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232003761">(Mar 26 2021 at 17:29)</a>:</h4>
<p>but that blog post does not attempt to address/evaluate the current state of LLVM’s <code>dereferencable</code> attribute. I would like to make a decision here that is <em>independent</em> of the state of that attribute, but maybe that is not realistc...</p>



<a name="232009075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232009075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232009075">(Mar 26 2021 at 18:05)</a>:</h4>
<p>I'll read that write up -- I was planning to ping you <span class="user-mention" data-user-id="116083">@pnkfelix</span> but keep running out of cycles to do so... we should prepare an agenda of some kind</p>



<a name="232018340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232018340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232018340">(Mar 26 2021 at 19:18)</a>:</h4>
<p>Thoughts on a <code>*const</code> API with my libs team hat on:</p>
<ul>
<li>I don't think confusion by users is going to be a significant issue. The <code>*const</code> API will clearly be named as a "raw" API, it will be <code>unsafe</code> and the docs will recommend using <code>Atomic*</code> instead.</li>
<li>Having an API to atomically mutate a <code>*const Inner</code> is useful to have in general, especially for FFI which doesn't use atomic types.</li>
</ul>



<a name="232024493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232024493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232024493">(Mar 26 2021 at 20:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232009075">said</a>:</p>
<blockquote>
<p>I'll read that write up -- I was planning to ping you <span class="user-mention silent" data-user-id="116083">pnkfelix</span> but keep running out of cycles to do so... we should prepare an agenda of some kind</p>
</blockquote>
<p>Yes, my current plan is to construct a much smaller agenda for the lang-team meeting by trying to condense that writeup into something a lang team member could read in five minutes.</p>



<a name="232028807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232028807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232028807">(Mar 26 2021 at 20:41)</a>:</h4>
<p>Hm, ok</p>



<a name="232028819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232028819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232028819">(Mar 26 2021 at 20:41)</a>:</h4>
<p>That seems like the right goal</p>



<a name="232028908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232028908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232028908">(Mar 26 2021 at 20:42)</a>:</h4>
<p>I keep going back to the question of trying to dive back into the previous discussions related to this topic</p>



<a name="232028926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232028926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232028926">(Mar 26 2021 at 20:42)</a>:</h4>
<p>but they get really unwieldy, and I want this to be a bit more focused</p>



<a name="232029444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029444">(Mar 26 2021 at 20:47)</a>:</h4>
<p>Yeah, that was my impression based on a few brief forays</p>



<a name="232029595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029595">(Mar 26 2021 at 20:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232003686">said</a>:</p>
<blockquote>
<p>I made a write up, then I decided the write-up was not approrpriate for the lang team meeting (too long winded), so I turned it into a blog post because I couldn’t bear to throw it away: <a href="http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/">http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/</a></p>
</blockquote>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I’m sort of dreading pointing you at this, because its pretty long-winded, and ends up not even saying that much in the end.</p>



<a name="232029637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029637">(Mar 26 2021 at 20:49)</a>:</h4>
<p>but at the same time, I expect you (Ralf) might have insight into other points in the domain that I failed to distinguish/consider.</p>



<a name="232029655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029655">(Mar 26 2021 at 20:49)</a>:</h4>
<p>(both problem and solution domains, that is.)</p>



<a name="232029779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029779">(Mar 26 2021 at 20:50)</a>:</h4>
<p>I think it feels like your blog post identifies pretty clearly a couple models we <em>could</em> go with -- I've not yet formed a position of preference, though I do have thoughts -- I'm wondering if the right shape for the meeting is to:</p>
<ul>
<li>read a prepared summary of the problem</li>
<li>read a prepared summary of the available options (your models at least, potentially coming up with some new ones)</li>
<li>discuss, in the hopes of identifying how we want to move forward (i.e., on which model)</li>
</ul>
<p>I am a bit of the mind that perhaps the last point here is not actually right -- it seems pretty likely that we'd not be able to come to a reasonable understanding in the meeting <em>and</em> arrive at any kind of consensus; these topics at least for me really require some idle thinking time</p>



<a name="232029872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029872">(Mar 26 2021 at 20:51)</a>:</h4>
<p>so I'm wondering if the right thing is that we instead <em>focus</em> the meeting on a collaborative exploration of the design space, potentially even without all of lang in attendance -- in the hopes of actually coming up with the first two bullets I had prepared, which can then be more asynchronously digested and such</p>



<a name="232029960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029960">(Mar 26 2021 at 20:52)</a>:</h4>
<p>maybe</p>



<a name="232029990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232029990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232029990">(Mar 26 2021 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> ’s comment above makes me worry that I was too quick to dismiss a raw API</p>



<a name="232030084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030084">(Mar 26 2021 at 20:53)</a>:</h4>
<p>but I think I <em>like</em> the philosophy that “deallocation capability should be on same footing as mutation capability” w.r.t reasoning. Something really sings to me about that.</p>



<a name="232030183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030183">(Mar 26 2021 at 20:54)</a>:</h4>
<p>even though I’m not sure if its entirely coherent (given that you can attach <code>UnsafeCell</code> to only <em>part</em> of a memory block you’ve allocated…)</p>



<a name="232030195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030195">(Mar 26 2021 at 20:54)</a>:</h4>
<p>Yeah, that's my worry with it</p>



<a name="232030252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030252">(Mar 26 2021 at 20:55)</a>:</h4>
<p>it feels like what that the coherent expectation would be UnsafeCell&lt;MaybeUninit&lt;T&gt;&gt; gives you that</p>



<a name="232030353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030353">(Mar 26 2021 at 20:55)</a>:</h4>
<p>hmm.  You think the <code>MaybeUninit</code> needs to be part of the story?</p>



<a name="232030428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030428">(Mar 26 2021 at 20:56)</a>:</h4>
<p>Well, to me, UnsafeCell does not imply no validity invariant, whereas deallocation (to some extent) implies replacement with uninit memory, right?</p>



<a name="232030481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030481">(Mar 26 2021 at 20:56)</a>:</h4>
<p>Though we've certainly oscillated on whether e.g. UnsafeCell&lt;bool&gt; can be a 0x3 in memory, I don't know if there's firm conclusions</p>



<a name="232030504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030504">(Mar 26 2021 at 20:57)</a>:</h4>
<p>deallocation to me is more severe than “replacement with uninit"</p>



<a name="232030554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030554">(Mar 26 2021 at 20:57)</a>:</h4>
<p>I agree :) But if it's <em>at least</em> that, then it seems like you should request a maybeuninit somewhere</p>



<a name="232030559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030559">(Mar 26 2021 at 20:57)</a>:</h4>
<p>but your point is that you do not think <code>UnsafeCell&lt;T&gt;</code> should suffice as a marker</p>



<a name="232030767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030767">(Mar 26 2021 at 20:59)</a>:</h4>
<p>I definitely don't think it should suffice for memory outside of it</p>



<a name="232030791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030791">(Mar 26 2021 at 20:59)</a>:</h4>
<p>(since I don't know where to stop then)</p>



<a name="232030928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030928">(Mar 26 2021 at 21:00)</a>:</h4>
<p>I could imagine ways to formalize its leakiness</p>



<a name="232030963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232030963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232030963">(Mar 26 2021 at 21:00)</a>:</h4>
<p>but I understand the concern</p>



<a name="232031018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031018">(Mar 26 2021 at 21:01)</a>:</h4>
<p>the main thing for me is whether we try to come up with something that is likely to work with existing coding patterns that are modelled after what <code>Arc</code> does</p>



<a name="232031032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031032">(Mar 26 2021 at 21:01)</a>:</h4>
<p>or do we require something new</p>



<a name="232031334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031334">(Mar 26 2021 at 21:03)</a>:</h4>
<p>Yeah, I'm not sure. I lean towards saying we should work with existing patterns, but I think ultimately I'd prefer to aim for a model that feels pretty easily explainable. I think saying that UnsafeCell, for example, combines both mutation and deallocation, that seems coherent to me; I think the interaction with MaybeUninit is a bit fuzzy but not too bad.</p>
<p>That might mean that in the Arc example, we would indeed need a rewrite to have UnsafeCell&lt;Inner&gt;; that seems a bit unfortunate, as the compiler cannot "know" then that the T is <em>not</em> permitted to be mutated, only deallocated</p>



<a name="232031349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031349">(Mar 26 2021 at 21:03)</a>:</h4>
<p>(though I'm trying to understand why that matters)</p>



<a name="232031465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031465">(Mar 26 2021 at 21:04)</a>:</h4>
<p>Interesting</p>



<a name="232031532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031532">(Mar 26 2021 at 21:05)</a>:</h4>
<p>I was hoping to make <code>Arc</code> work soley from the presence of <code>UnsafeCell</code> within the <code>AtomicUsize</code>, but yes, then we hit the problem you were noting earlier of having to define “where does it stop"</p>



<a name="232031562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031562">(Mar 26 2021 at 21:05)</a>:</h4>
<p>anyway we can try to leave this discussion for the meeting</p>



<a name="232031580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031580">(Mar 26 2021 at 21:05)</a>:</h4>
<p>well, maybe</p>



<a name="232031638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031638">(Mar 26 2021 at 21:06)</a>:</h4>
<p>but its good stuff to try to figure out how to summarize concisely.</p>



<a name="232031643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031643">(Mar 26 2021 at 21:06)</a>:</h4>
<p>I'm not sure if it's helpful to come in with a well understood framework/design space</p>



<a name="232031668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031668">(Mar 26 2021 at 21:06)</a>:</h4>
<p>(at least by someone)</p>



<a name="232031865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031865">(Mar 26 2021 at 21:08)</a>:</h4>
<p>… either you have a typo, or you’re saying that doing design before the meeting will just mean people will be confused by the design at the meeting?</p>



<a name="232031990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232031990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232031990">(Mar 26 2021 at 21:09)</a>:</h4>
<p>No, I'm saying -- do we want to do design in the meeting? Or choose amongst a set of options (potentially finding a combination between them)</p>



<a name="232032031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032031">(Mar 26 2021 at 21:09)</a>:</h4>
<p>I was seeing this conversation as trying to come up with some set of options and a framework of pros/cons pre-identified</p>



<a name="232032095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032095">(Mar 26 2021 at 21:10)</a>:</h4>
<p>Right, okay</p>



<a name="232032103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032103">(Mar 26 2021 at 21:10)</a>:</h4>
<p>(and I see that as helpful for the meeting, but if it feels differently to you, perhaps we shouldn't do it :)</p>



<a name="232032165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032165">(Mar 26 2021 at 21:10)</a>:</h4>
<p>Well…</p>



<a name="232032178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032178">(Mar 26 2021 at 21:11)</a>:</h4>
<p>I guess I’m dividied</p>



<a name="232032211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032211">(Mar 26 2021 at 21:11)</a>:</h4>
<p>on the one hand, I’m about to be called away, so I really can’t invest much time right now into <em>anything</em>. :)</p>



<a name="232032227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032227">(Mar 26 2021 at 21:11)</a>:</h4>
<p>but really, that ’s not an arguemnt against async discussion</p>



<a name="232032232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032232">(Mar 26 2021 at 21:11)</a>:</h4>
<p>what I <em>am</em> worried aobut</p>



<a name="232032292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032292">(Mar 26 2021 at 21:12)</a>:</h4>
<p>is not having a useful doc at all going into the meeting</p>



<a name="232032330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032330">(Mar 26 2021 at 21:12)</a>:</h4>
<p>so I guess its good to have this conversation, as long as it drives me towards coming up with something for the meeting itself.</p>



<a name="232032342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032342">(Mar 26 2021 at 21:12)</a>:</h4>
<p>Right, yeah, I don't necessarily think it needs to be a discussion, though that can be helpful to pull out into a doc</p>



<a name="232032361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032361">(Mar 26 2021 at 21:12)</a>:</h4>
<p>I'm happy to work on preparing the doc to some extent</p>



<a name="232032421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032421">(Mar 26 2021 at 21:13)</a>:</h4>
<p>are there other compiler optimizations that should be illustrated in the text?</p>



<a name="232032452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032452">(Mar 26 2021 at 21:13)</a>:</h4>
<p>or unsafe code examples that shoudl be in there?</p>



<a name="232032587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032587">(Mar 26 2021 at 21:13)</a>:</h4>
<p>you mean vs. your blog post?</p>



<a name="232032643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032643">(Mar 26 2021 at 21:14)</a>:</h4>
<p>yes. for the blog post, I chose something dirt simple</p>



<a name="232032660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032660">(Mar 26 2021 at 21:14)</a>:</h4>
<p>I think there was the Arc case, and there was a potentially similar but different case in the rayon library</p>



<a name="232032681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032681">(Mar 26 2021 at 21:14)</a>:</h4>
<p>(also with deallocation)</p>



<a name="232032702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032702">(Mar 26 2021 at 21:14)</a>:</h4>
<p>I don't know about compiler opts</p>



<a name="232032713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032713">(Mar 26 2021 at 21:14)</a>:</h4>
<p>i see. There are I think also examples of intrusive linked-lists where this problem arises</p>



<a name="232032737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032737">(Mar 26 2021 at 21:14)</a>:</h4>
<p>(the Rayon thing might be that, I’m not sure.)</p>



<a name="232032849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032849">(Mar 26 2021 at 21:15)</a>:</h4>
<p>yeah I forget too</p>



<a name="232032898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232032898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232032898">(Mar 26 2021 at 21:16)</a>:</h4>
<p>anyway, I'll see if I can find some time to invest in starting a draft layout and such</p>



<a name="232039451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232039451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232039451">(Mar 26 2021 at 22:18)</a>:</h4>
<p>Okay, but don’t worry too much about it <span class="user-mention" data-user-id="116122">@simulacrum</span> ; I know you have a lot of balls in the air</p>



<a name="232039498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232039498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232039498">(Mar 26 2021 at 22:18)</a>:</h4>
<p>Yeah, we'll see :)</p>



<a name="232075305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232075305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232075305">(Mar 27 2021 at 08:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232029637">said</a>:</p>
<blockquote>
<p>but at the same time, I expect you (Ralf) might have insight into other points in the domain that I failed to distinguish/consider.</p>
</blockquote>
<p>I saw the post in my RSS feed. :) I started reading and was really impressed by the depth and liked the approach of comparing directly with possible optimizations. Then I saw how long it is.^^ Given my backlog, I estimate I won't have time to read it this week-end. I hope I can read it next week-end.</p>



<a name="232075383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232075383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232075383">(Mar 27 2021 at 08:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232030183">said</a>:</p>
<blockquote>
<p>even though I’m not sure if its entirely coherent (given that you can attach <code>UnsafeCell</code> to only <em>part</em> of a memory block you’ve allocated…)</p>
</blockquote>
<p>I think that's pretty clear -- a deallocation is like a write <em>to the entire allocation</em>. That should make it coherent pretty easily, no?</p>



<a name="232075430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232075430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232075430">(Mar 27 2021 at 08:43)</a>:</h4>
<p>And I think that's enough for <code>Arc</code> -- AFAIK the only "must stay alive" references we have there are <code>&amp;AtomicUsize</code>, not <code>&amp;ArcInner</code></p>



<a name="232075591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232075591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232075591">(Mar 27 2021 at 08:46)</a>:</h4>
<blockquote>
<p>Having an API to atomically mutate a *const Inner is useful to have in general, especially for FFI which doesn't use atomic types.</p>
</blockquote>
<p>Sure, but what is not clear is if that API should ever be <em>required</em>. If we go with "mutable memory can be deallocated", then is it the case that one can implement the raw API by turning <code>*const Inner</code> to <code>&amp;AtomicUsize</code> and using the reference-based API? I think so.</p>



<a name="232130876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232130876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232130876">(Mar 28 2021 at 01:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232075383">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232030183">said</a>:</p>
<blockquote>
<p>even though I’m not sure if its entirely coherent (given that you can attach <code>UnsafeCell</code> to only <em>part</em> of a memory block you’ve allocated…)</p>
</blockquote>
<p>I think that's pretty clear -- a deallocation is like a write <em>to the entire allocation</em>. That should make it coherent pretty easily, no?</p>
</blockquote>
<p>But this is in the context of a claim that a <code>&amp;UnsafeCell&lt;T&gt;</code> (or <code>&amp;mut T</code>?) gives you access to mutate and maybe deallocate the <code>T</code>; if the deallocation is extends beyond the unsafe cell itself then that means that you can get a double-free by deallocating a <code>&amp;mut (T, T)</code> twice via its two projections</p>



<a name="232154260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154260">(Mar 28 2021 at 09:14)</a>:</h4>
<blockquote>
<p>But this is in the context of a claim that a &amp;UnsafeCell&lt;T&gt; (or &amp;mut T?) gives you access to mutate and maybe deallocate the T; if the deallocation is extends beyond the unsafe cell itself then that means that you can get a double-free by deallocating a &amp;mut (T, T) twice via its two projections</p>
</blockquote>
<p>I am thoroughly confused now.</p>



<a name="232154268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154268">(Mar 28 2021 at 09:14)</a>:</h4>
<p>There is no operating in Rust to deallocate the <code>T</code> part of a <code>(T, T)</code></p>



<a name="232154269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154269">(Mar 28 2021 at 09:14)</a>:</h4>
<p>I am not proposing to change that, and <code>UnsafCell</code> does not change that.</p>



<a name="232154296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154296">(Mar 28 2021 at 09:15)</a>:</h4>
<p>I am just say that when something is deallocated (which is inherently going to be an entire allocated object, not just a part of it), then the entire deallocated memory range must be writable through the pointer you are using for deallocation.</p>



<a name="232154359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154359">(Mar 28 2021 at 09:16)</a>:</h4>
<p>deallocation, just like reads and writes, is an operation on <em>memory ranges</em>, not just individual addresses. clearly, reading 2 bytes starting at ptr <code>p</code> is very different from reading 4 bytes starting at ptr <code>p</code>.</p>



<a name="232154444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232154444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232154444">(Mar 28 2021 at 09:18)</a>:</h4>
<p>From all of the above it follows that <code>UnsafeCell&lt;T&gt;</code> gives you access to deallocate the <code>T</code> <em>and just the <code>T</code></em>. If the allocated object is larger than the <code>T</code>, then you may not deallocate the rest of the allocated object. in practice this means you cannot deallocate the <code>T</code> either, but that is not a consequence of the aliasing rules (they are being very reasonable and compositional here), it is a consequence of the allocator API which does not permit deallocating a part of an allocated object.</p>



<a name="232158347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158347">(Mar 28 2021 at 10:36)</a>:</h4>
<p>In that case, isn't this "permission to deallocate" a bit useless? In particular, it doesn't validate the <code>Arc</code> functions</p>



<a name="232158472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158472">(Mar 28 2021 at 10:39)</a>:</h4>
<p>it does validate the <code>Arc</code> functions</p>



<a name="232158479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158479">(Mar 28 2021 at 10:39)</a>:</h4>
<p>the only reference that is still alive and potentially in conflict with the deallocation is the <code>&amp;AtomicUsize</code> of other thread that just did their last decrement</p>



<a name="232158558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158558">(Mar 28 2021 at 10:40)</a>:</h4>
<p>the reason that reference is a problem is that its item in the borrow stack is protected, so it may not be removed from the stack while the function associated with the item still runs (that function is <code>compare_exchange</code> or whatever atomic op is doing the decrement)</p>



<a name="232158585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158585">(Mar 28 2021 at 10:41)</a>:</h4>
<p>I thought the <code>&amp;Arc&lt;T&gt;</code> (and possibly the <code>&amp;ArcInner&lt;T&gt;</code> as well) are being held in locals up the call stack</p>



<a name="232158588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158588">(Mar 28 2021 at 10:41)</a>:</h4>
<p>but the item is a <code>SharedReadWrite</code>, so it is completely fine with mutation</p>



<a name="232158590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158590">(Mar 28 2021 at 10:41)</a>:</h4>
<p>those locals are never used again and their borrow stack items are not protected so that's fine</p>



<a name="232158629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158629">(Mar 28 2021 at 10:42)</a>:</h4>
<p>also <code>&amp;Arc</code> doesnt even point to the same allocation so it is irrelevant here</p>



<a name="232158668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158668">(Mar 28 2021 at 10:43)</a>:</h4>
<p>But that does mean that the <code>&amp;ArcInner&lt;T&gt;</code> refcount decrease can't be put in a function, right?</p>



<a name="232158692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158692">(Mar 28 2021 at 10:43)</a>:</h4>
<p>because then it would also be protected</p>



<a name="232158732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158732">(Mar 28 2021 at 10:44)</a>:</h4>
<p>there <em>would</em> be a problem if we added an extra method</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">do_decrement</span><span class="p">(</span><span class="n">ptr</span>: <span class="kp">&amp;</span><span class="nc">ArcInner</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">ptr</span><span class="p">.</span><span class="n">fetch_sub</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>and called that from <code>drop_slow</code> (instead of directly calling <code>fetch_sub</code> or whatever). this is a problem because then there'd be a <code>&amp;ArcInner</code> pointer with protected items on the borrow stack, and some of those items (the one covering the <code>T</code>) are <em>not</em> okay with writes since they are <code>SharedReadOnly</code></p>



<a name="232158744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158744">(Mar 28 2021 at 10:44)</a>:</h4>
<p>yes we were typing concurrently ;)</p>



<a name="232158762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158762">(Mar 28 2021 at 10:45)</a>:</h4>
<p>but there'd also be a fix here -- use <code>NonNull</code> (or raw ptrs or so) instead of <code>&amp;</code></p>



<a name="232158994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158994">(Mar 28 2021 at 10:49)</a>:</h4>
<p>I never said this wasn't subtle. ;)</p>



<a name="232158999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232158999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232158999">(Mar 28 2021 at 10:49)</a>:</h4>
<p>Hm, this seems to solve the problem. +1 from me</p>



<a name="232365393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232365393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232365393">(Mar 30 2021 at 02:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232158732">said</a>:</p>
<blockquote>
<p>there <em>would</em> be a problem if we added an extra method</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">do_decrement</span><span class="p">(</span><span class="n">ptr</span>: <span class="kp">&amp;</span><span class="nc">ArcInner</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">ptr</span><span class="p">.</span><span class="n">fetch_sub</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>and called that from <code>drop_slow</code> (instead of directly calling <code>fetch_sub</code> or whatever). this is a problem because then there'd be a <code>&amp;ArcInner</code> pointer with protected items on the borrow stack, and some of those items (the one covering the <code>T</code>) are <em>not</em> okay with writes since they are <code>SharedReadOnly</code></p>
</blockquote>
<p>The blog post tries to tease out these distinctions by making an explicit matrix covering them. I’d like to know whether I got it right nor not.</p>



<a name="232365714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232365714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232365714">(Mar 30 2021 at 02:51)</a>:</h4>
<p>Namely, I <em>think</em> you are describing <a href="http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/#Version.2:..inner-ref.handled.out-of-line.">version 2</a> as problematic. But I think that you are also saying that <a href="http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/#Version.4:..atomic-ref.handled.out-of-line.">version 4</a> is <strong>not</strong> problematic.</p>



<a name="232365871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232365871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232365871">(Mar 30 2021 at 02:53)</a>:</h4>
<p>Which may mean that you are saying <a href="http://blog.pnkfx.org/blog/2021/03/25/how-to-dismantle-an-atomic-bomb/#Option.4..Put.deallocation.on.same.footing.as.mutation">Option 4</a> in my blog post would work. (Specifically 4A… i think…)</p>



<a name="232367708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232367708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232367708">(Mar 30 2021 at 03:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> at this point I’m doing my expurgated version of the blog post here: <a href="https://hackmd.io/p0sspE8pSSSfBuLV0EwIlw">https://hackmd.io/p0sspE8pSSSfBuLV0EwIlw</a></p>



<a name="232367848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232367848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232367848">(Mar 30 2021 at 03:22)</a>:</h4>
<p>Sounds good. I expect to devote an hour tomorrow to this, likely in the morning, FWIW - not sure how much I'll be able to get done, but can help clean things up or get them into better shape, at least, or draft some additional explanations/thinking.</p>



<a name="232368540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232368540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232368540">(Mar 30 2021 at 03:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232075383">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232030183">said</a>:</p>
<blockquote>
<p>even though I’m not sure if its entirely coherent (given that you can attach <code>UnsafeCell</code> to only <em>part</em> of a memory block you’ve allocated…)</p>
</blockquote>
<p>I think that's pretty clear -- a deallocation is like a write <em>to the entire allocation</em>. That should make it coherent pretty easily, no?</p>
</blockquote>
<p>As in: If you <em>do</em> have a <code>&amp;ArcInner</code> lying around when the deallocation happens, then that’s breaking the rules, right? It needs to be narrowed to just the <code>&amp;AtomicUsize</code>, because you need to narrow the scope of the reference that overlaps to the write to just the thing that is a trivial wrapper around <code>UnsafeCell</code> ?</p>



<a name="232427185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232427185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232427185">(Mar 30 2021 at 13:43)</a>:</h4>
<p>This seems pretty good -- I think I'm happy to try to go for it in the meeting tomorrow.</p>



<a name="232451339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232451339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232451339">(Mar 30 2021 at 16:03)</a>:</h4>
<p>Btw, just wanted to thank you <span class="user-mention" data-user-id="116083">@pnkfelix</span> for that blog post you published; I had somehow inferred the issues at had out of random fragments out of this very lengthy topic, but your blog post very clearly curated the information in a well-ordered manner <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="232456080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232456080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232456080">(Mar 30 2021 at 16:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232368540">said</a>:</p>
<blockquote>
<p>As in: If you <em>do</em> have a <code>&amp;ArcInner</code> lying around when the deallocation happens, then that’s breaking the rules, right? It needs to be narrowed to just the <code>&amp;AtomicUsize</code>, because you need to narrow the scope of the reference that overlaps to the write to just the thing that is a trivial wrapper around <code>UnsafeCell</code> ?</p>
</blockquote>
<p>It is okay if the <code>&amp;ArcInner</code> is in a local variable that is never used again, because these are not "stack-protected" and so they can become invalid before drop (because they have no drop glue). But if the <code>&amp;ArcInner</code> is a function parameter, then it is stack-protected, meaning that it has to be valid until the end of the function, even if it is never used again in either this function or the caller.</p>



<a name="232456759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232456759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232456759">(Mar 30 2021 at 16:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232368540">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232075383">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232030183">said</a>:</p>
<blockquote>
<p>even though I’m not sure if its entirely coherent (given that you can attach <code>UnsafeCell</code> to only <em>part</em> of a memory block you’ve allocated…)</p>
</blockquote>
<p>I think that's pretty clear -- a deallocation is like a write <em>to the entire allocation</em>. That should make it coherent pretty easily, no?</p>
</blockquote>
<p>As in: If you <em>do</em> have a <code>&amp;ArcInner</code> lying around when the deallocation happens, then that’s breaking the rules, right? It needs to be narrowed to just the <code>&amp;AtomicUsize</code>, because you need to narrow the scope of the reference that overlaps to the write to just the thing that is a trivial wrapper around <code>UnsafeCell</code> ?</p>
</blockquote>
<p>yes, basically. the <code>&amp;ArcInner</code> becomes invalid at that point (and if it is protected, that's immediate UB; else its just UB if its used again)</p>



<a name="232456824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232456824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232456824">(Mar 30 2021 at 16:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232427185">said</a>:</p>
<blockquote>
<p>This seems pretty good -- I think I'm happy to try to go for it in the meeting tomorrow.</p>
</blockquote>
<p>I just realized that meeting overlaps with the "social event" at ETAPS :/</p>



<a name="232456991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232456991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232456991">(Mar 30 2021 at 16:39)</a>:</h4>
<p>"an escape game social event", sounds interesting...</p>



<a name="232459213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459213">(Mar 30 2021 at 16:53)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> the point you’re making about the impact of “stack-protection” on the local-variable vs function parameter question: That’s a property that comes from stacked borrows, right? Am I correct in inferring that the semantics there has no notion of inlining? (In the sense that if inlining does happen, it is an implementation detail, and cannot affect the semantic rules being described.)</p>



<a name="232459563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459563">(Mar 30 2021 at 16:55)</a>:</h4>
<p>That's a good question. I think you can recover inlining by inserting a fake read after the function body when performing an inlining operation</p>



<a name="232459623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459623">(Mar 30 2021 at 16:55)</a>:</h4>
<p>It sounds like there’s some variant that I have failed to describe in my write-up, where the out-of-line <code>&amp;Inner</code> decrement is not okay, but the other three quadrants of the matrix are all okay.</p>



<a name="232459761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459761">(Mar 30 2021 at 16:56)</a>:</h4>
<p>I’ll make sure to include that in my doc for the design meeting tomorrow.</p>



<a name="232459922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459922">(Mar 30 2021 at 16:57)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> is there a way to introduce a stack protector besides a function call? I.e. is there some way to make the local variable treated the same way as the function parameter?</p>



<a name="232459966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459966">(Mar 30 2021 at 16:57)</a>:</h4>
<p>Although I think this doesn't affect the validity of inlining but rather outlining - the UB is introduced by adding a stack protector, not by removing one</p>



<a name="232459977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232459977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232459977">(Mar 30 2021 at 16:57)</a>:</h4>
<p>(Maybe that is what you are saying when you are suggesting inserting a fake read after the function body when inlining...)</p>



<a name="232460181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232460181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232460181">(Mar 30 2021 at 16:58)</a>:</h4>
<p>(Okay correction, sounds like the fake read doesn’t insert a protector)</p>



<a name="232460186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232460186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232460186">(Mar 30 2021 at 16:58)</a>:</h4>
<p>I believe the effect of a stack protector is the same as inserting a read of all the parameters in the function epilogue</p>



<a name="232460239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232460239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232460239">(Mar 30 2021 at 16:58)</a>:</h4>
<p>Heh I’m really ping-ponging here.</p>



<a name="232460385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232460385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232460385">(Mar 30 2021 at 16:59)</a>:</h4>
<p>so for the same reason that you can drop a dead read, you can also inline a function, but you can't necessarily reverse that - insert a read or outline a function</p>



<a name="232460498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232460498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232460498">(Mar 30 2021 at 17:00)</a>:</h4>
<p>(you being the compiler)</p>



<a name="232557632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232557632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232557632">(Mar 31 2021 at 09:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232459922">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> is there a way to introduce a stack protector besides a function call? I.e. is there some way to make the local variable treated the same way as the function parameter?</p>
</blockquote>
<p>no, not currently.</p>



<a name="232557754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232557754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232557754">(Mar 31 2021 at 09:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232460186">said</a>:</p>
<blockquote>
<p>I believe the effect of a stack protector is the same as inserting a read of all the parameters in the function epilogue</p>
</blockquote>
<p>no, it is not. the stack protector is stronger, since it causes <em>immediate</em> UB to invalidate them.<br>
you cannot simulate this with a read of all parameters at the end since the function might never return, so those reads might never happen.</p>



<a name="232557822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Whither%20%2AAtomic%20API%20duplication/near/232557822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication.html#232557822">(Mar 31 2021 at 09:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/Whither.20*Atomic.20API.20duplication/near/232460385">said</a>:</p>
<blockquote>
<p>so for the same reason that you can drop a dead read, you can also inline a function, but you can't necessarily reverse that - insert a read or outline a function</p>
</blockquote>
<p>correct. (or rather, when you do outlining, you have to generate a function that doesn't add stack protectors. in MIR this is possible; surface Rust doesn't have syntax for that. this would also have to affect the LLVM attributes emitted for this function, which is not currently implemented.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>